//
//  DemoTableViewCell.m
//  dome01
//
//  Created by Mac－mini on 2017/5/11.
//  Copyright © 2017年 com.hqc.www. All rights reserved.
//

#import "DemoTableViewCell.h"



#define kScreenWidth [UIScreen mainScreen].bounds.size.width

@interface DemoTableViewCell()
@property (nonatomic, strong) NSArray *array;


@end

@implementation DemoTableViewCell

- (NSArray *)array {
    if (!_array) {
        _array = @[@"AQI", @"PM2.5", @"PM10", @"SO2", @"NO2", @"CO", @"O3"];
    }
    return _array;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configUI];
    }
    return self;
}

- (void) configUI {
    
    UIView *topView = [[UIView alloc]init];
    [self.contentView addSubview:topView];
    topView.backgroundColor = [UIColor lightGrayColor];
    _topView = topView;
    
    UILabel *cityLable = [[UILabel alloc]init];
    [_topView addSubview:cityLable];
    cityLable.textColor = [UIColor blueColor];
    cityLable.font = [UIFont systemFontOfSize:12];
    _cityLabel = cityLable;
    
    UILabel *humiLabel = [[UILabel alloc]init];
    [_topView addSubview:humiLabel];
    humiLabel.font = [UIFont systemFontOfSize:12];
    _humiLabel = humiLabel;
    
    UILabel *windlabel = [[UILabel alloc]init];
    [_topView addSubview:windlabel];
    windlabel.font = [UIFont systemFontOfSize:12];
    _windlabel = windlabel;
    
    UIImageView *windImgV = [[UIImageView alloc]init];
    [_topView addSubview:windImgV];
    _windImgV = windImgV;
    
    UILabel *timeLabel = [[UILabel alloc]init];
    [_topView addSubview:timeLabel];
    timeLabel.font = [UIFont systemFontOfSize:12];
    _timeLabel = timeLabel;
    
    UIView *pollutantView = [[UIView alloc]init];
    [self.contentView addSubview:pollutantView];
    
    _pollutantView = pollutantView;
    
    UILabel *aqiLableT = [[UILabel alloc]init];
    aqiLableT.font = [UIFont systemFontOfSize:12];
    [_pollutantView addSubview:aqiLableT];
    _aqiLableT = aqiLableT;
    
    UILabel *aqiLableB = [[UILabel alloc]init];
    aqiLableB.font = [UIFont systemFontOfSize:12];
    [_pollutantView addSubview:aqiLableB];
    _aqiLableB = aqiLableB;
    
    UILabel *pm2_5LabelT = [[UILabel alloc]init];
    pm2_5LabelT.font = [UIFont systemFontOfSize:12];
    [_pollutantView addSubview:pm2_5LabelT];
    _pm2_5LabelT = pm2_5LabelT;
    
    UILabel *pm2_5LabelB = [[UILabel alloc]init];
    pm2_5LabelB.font = [UIFont systemFontOfSize:12];
    [_pollutantView addSubview:pm2_5LabelB];
    _pm2_5LabelB = pm2_5LabelB;
    
    UILabel *pm10LabelT = [[UILabel alloc]init];
    pm10LabelT.font = [UIFont systemFontOfSize:12];
    [_pollutantView addSubview:pm10LabelT];
    _pm10LabelT = pm10LabelT;
    
    UILabel *pm10LabelB = [[UILabel alloc]init];
    pm10LabelB.font = [UIFont systemFontOfSize:12];
    [_pollutantView addSubview:pm10LabelB];
    _pm10LabelB = pm10LabelB;
    
    UILabel *so2LabelT = [[UILabel alloc]init];
    so2LabelT.font = [UIFont systemFontOfSize:12];
    [_pollutantView addSubview:so2LabelT];
    _so2LabelT = so2LabelT;
    
    UILabel *so2LabelB = [[UILabel alloc]init];
    so2LabelB.font = [UIFont systemFontOfSize:12];
    [_pollutantView addSubview:so2LabelB];
    _so2LabelB = so2LabelB;
    
    UILabel *no2LabelT = [[UILabel alloc]init];
    no2LabelT.font = [UIFont systemFontOfSize:12];
    [_pollutantView addSubview:no2LabelT];
    _no2LabelT = no2LabelT;
    
    UILabel *no2LabelB = [[UILabel alloc]init];
    no2LabelB.font = [UIFont systemFontOfSize:12];
    [_pollutantView addSubview:no2LabelB];
    _no2LabelB = no2LabelB;
    
    UILabel *coLabelT = [[UILabel alloc]init];
    coLabelT.font = [UIFont systemFontOfSize:12];
    [_pollutantView addSubview:coLabelT];
    _coLabelT = coLabelT;
    
    UILabel *coLabelB = [[UILabel alloc]init];
    coLabelB.font = [UIFont systemFontOfSize:12];
    [_pollutantView addSubview:coLabelB];
    _coLabelB = coLabelB;
    
    UILabel *o3LabelT = [[UILabel alloc]init];
    o3LabelT.font = [UIFont systemFontOfSize:12];
    [_pollutantView addSubview:o3LabelT];
    _o3LabelT = o3LabelT;
    
    UILabel *o3LabelB = [[UILabel alloc]init];
    o3LabelB.font = [UIFont systemFontOfSize:12];
    [_pollutantView addSubview:o3LabelB];
    _o3LabelB = o3LabelB;
    
    UIView *bommotView = [[UIView alloc]init];
    [self.contentView addSubview:bommotView];
    _bommotView = bommotView;
    
    UISegmentedControl *segmentedControl = [[UISegmentedControl alloc]initWithItems:self.array];
    segmentedControl.selectedSegmentIndex = 0;
    [bommotView addSubview:segmentedControl];
    [segmentedControl addTarget:self action:@selector(segmetedChaged:) forControlEvents:UIControlEventValueChanged];
    _segmentedControl = segmentedControl;
    
    
    
    
}

- (void)layoutSubviews {
    
    _topView.frame      = CGRectMake(0, 0, kScreenWidth, 20);
    _cityLabel.frame    = CGRectMake(5, 0, 100, 20);
    _humiLabel.frame    = CGRectMake(CGRectGetMaxX(_cityLabel.frame)+150, CGRectGetMidY(_cityLabel.frame), 20, 20);
    CGFloat timeW       = 200;
    CGFloat timeX       = kScreenWidth - timeW;
    _timeLabel.frame    = CGRectMake(timeX, CGRectGetMidY(_cityLabel.frame), timeW, 20);
    
    CGFloat vFloatW      = kScreenWidth/7.0;
    _pollutantView.frame = CGRectMake(0, CGRectGetMaxY(_topView.frame), kScreenWidth, 40);
    _aqiLableT.frame     = CGRectMake(0, 0, vFloatW , 20);
    _aqiLableB.frame     = CGRectMake(0, 20, vFloatW, 20);
    
    _pm2_5LabelT.frame   = CGRectMake(CGRectGetMaxX(_aqiLableT.frame), 0, vFloatW , 20);
    _pm2_5LabelB.frame   = CGRectMake(CGRectGetMaxX(_aqiLableT.frame), 20, vFloatW, 20);
    
    _pm10LabelT.frame    = CGRectMake(CGRectGetMaxX(_pm2_5LabelT.frame), 0, vFloatW , 20);
    _pm10LabelB.frame    = CGRectMake(CGRectGetMaxX(_pm2_5LabelT.frame), 20, vFloatW, 20);
    
    _so2LabelT.frame     = CGRectMake(CGRectGetMaxX(_pm10LabelT.frame), 0, vFloatW , 20);
    _so2LabelB.frame     = CGRectMake(CGRectGetMaxX(_pm10LabelT.frame), 20, vFloatW, 20);
    
    _no2LabelT.frame     = CGRectMake(CGRectGetMaxX(_so2LabelT.frame), 0, vFloatW , 20);
    _no2LabelB.frame     = CGRectMake(CGRectGetMaxX(_so2LabelT.frame), 20, vFloatW, 20);
    
    _coLabelT.frame      = CGRectMake(CGRectGetMaxX(_no2LabelT.frame), 0, vFloatW , 20);
    _coLabelB.frame      = CGRectMake(CGRectGetMaxX(_no2LabelT.frame), 20, vFloatW, 20);
    
    _o3LabelT.frame      = CGRectMake(CGRectGetMaxX(_coLabelT.frame), 0, vFloatW , 20);
    _o3LabelB.frame      = CGRectMake(CGRectGetMaxX(_coLabelT.frame), 20, vFloatW, 20);
    
    _bommotView.frame = CGRectMake(0, CGRectGetMaxY(_pollutantView.frame), kScreenWidth, _bommotHeight);

    
}




- (void)segmetedChaged:(UISegmentedControl *)sender {
    
}

- (void)setModel:(FiveDataModel *)model {
    _model = model;
    
    _cityLabel.text = [NSString stringWithFormat:@"[%@]%@",model.region,model.pointname];
    _humiLabel.text = [NSString stringWithFormat:@"湿:%@%",model.humi];
    _windlabel.text = [NSString stringWithFormat:@"风:%@m/s", model.ws];
}



@end
